String userName = "admin"; String password = "admin"; UserCredential credential = new UsernamePasswordCredential(userName, password);
This section describes how to authenticate users using the username and password as credentials.
This authentication type is provided by the org.picketbox.core.authentication.impl.UserNamePasswordAuthenticationMechanism.
You do not need any specific configuration to use this mechanism, it is already configured when you start PicketBox.
This mechanism supports the following credential:
org.picketbox.core.authentication.credential.UsernamePasswordCredential
The code bellow demonstrates how to create this credential type.
String userName = "admin"; String password = "admin"; UserCredential credential = new UsernamePasswordCredential(userName, password);
PicketBoxManager picketBoxManager = createManager();
UserContext authenticatingContext = new UserContext();
authenticatingContext.setCredential(new UsernamePasswordCredential("admin", "admin"));
UserContext authenticatedContext = picketBoxManager.authenticate(authenticatingContext);
assertNotNull(authenticatedContext);
assertNotNull(authenticatedContext.isAuthenticated());